Skip to content

Conversation

@SimonBarrettACT
Copy link

@SimonBarrettACT SimonBarrettACT commented Apr 13, 2025

Description

This pull request enhances the Onym package by making the separator used across different strategies fully customizable.

Previously, the timestamp(), date(), and numbered() methods hard-coded the separator (e.g., underscore _) into their generated filenames. There was no way to override it dynamically through options.

This PR introduces:

  • Support for a separator option in all relevant methods (timestamp, date, numbered, and slug).
  • Fallback to a defaultSeparator if no separator is provided in options.
  • The ability to override options and defaultSeparator through the constructor, making the class easier to customize and test.

Example usage:

use Blaspsoft\Onym\Onym;

// Set a custom default separator
$onym = new Onym([], ' ');
$filename = $onym->timestamp('invoice', 'pdf'); // 2024-03-15 invoice.pdf

// Or override per call
$filename = $onym->timestamp('invoice', 'pdf', ['separator' => ' ']); // 2024-03-15 invoice.pdf

@deemonic
Copy link
Collaborator

deemonic commented Apr 13, 2025

Hi @SimonBarrettACT

Thanks for this addition I can see the value.

I just wanted to acknowledge the request I'll try and look as this and get this merged later today. If not it will be Wednesday as im travelling Monday / Tuesday.

I just wanted to let you know and set some expectation.

Your contribution is appreciated

Have a great day

@SimonBarrettACT
Copy link
Author

Would it be possible to merge this please 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants